import random

# 定义游戏中使用到的一些常量
MAX_ROUNDS = 10
MIN_PLAYERS = 2
MAX_PLAYERS = 6
DICE_SIDES = 6

# 初始化玩家列表和得分板
players = []
scoreboard = {}

# 设置玩家数量
num_players = input("请输入玩家数量: ")
while not num_players.isnumeric() or int(num_players) < MIN_PLAYERS or int(num_players) > MAX_PLAYERS:
    num_players = input(f"请输入 {MIN_PLAYERS} 和 {MAX_PLAYERS} 之间的数字: ")
num_players = int(num_players)

# 初始化玩家列表和得分板
for i in range(1, num_players+1):
    player_name = input(f"请输入第{i}位玩家的名字: ")
    players.append(player_name)
    scoreboard[player_name] = 0

# 游戏开始
for round in range(1, MAX_ROUNDS+1):
    print(f"第 {round} 轮开始了！")

    # 每位玩家轮流掷骰子
    for player in players:
        input(f"{player}，请按回车键投掷骰子...")
        roll = random.randint(1, DICE_SIDES)
        print(f"{player}投掷了 {roll} 点")

        # 根据得分情况判断是否有加分
        if roll % 2 == 0:
            points = roll * 2
            scoreboard[player] += points
            print(f"恭喜 {player}，你获得了 {points} 分！")
        else:
            points = roll * -1
            scoreboard[player] += points
            print(f"{player}，你失去了 {abs(points)} 分，好运会很快回来的！")

    # 输出当前得分情况
    print("当前得分情况:")
    for player, score in scoreboard.items():
        print(f"{player}: {score} 分")

# 游戏结束
print("游戏结束！最终得分情况:")
for player, score in scoreboard.items():
    print(f"{player}: {score} 分")
